<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    body{
        background-image: url('./images/desktop_1.jpg');
    }
</style>
<body>
    <script>
        //1.获取元素对象
        let Img=document.querySelector('body')
        //2.随机函数
        function getRandom(min,max){
            return (Math.floor(Math.random()*(max-min+1))+min)
        }
        //3.获取随机数
        let num=getRandom(1,10)
        //4.修改图片
        Img.style.backgroundImage=`url('./images/desktop_${num}.jpg')`

    </script>
</body>
</html>